package demo5;

import java.util.Arrays;

class Student  {
    String name;
    int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class Text {
    public static void main(String[] args) {
        Student[]students=new Student[3];
        students[0]=new Student("zhangsan",12);
        students[1]=new Student("lisi",8);
        students[2]=new Student("wamgwu",10);
        Namecomparator namecomparator=new Namecomparator();
        System.out.println(Arrays.toString(students));
        Arrays.sort(students,namecomparator);
        System.out.println(Arrays.toString(students));
    }
    public static void main1(String[] args) {
        Student student1=new Student("zhangsan",9);
        Student student2=new Student("lisi",10);


        Agecomparator agecomparator=new Agecomparator();
        int ret=agecomparator.compare(student1,student2);
        System.out.println(ret);

        Namecomparator namecomparator=new Namecomparator();
        int ret2=namecomparator.compare(student1,student2);
        System.out.println(ret2);
    }

}
